package com.zwh.se.design_pattern.creational.factory.b_simple_factory.controller;


import com.zwh.se.design_pattern.creational.factory.b_simple_factory.factory.FreeGoodsFactory;
import com.zwh.se.design_pattern.creational.factory.b_simple_factory.service.IFreeGoods;
import com.zwh.se.design_pattern.creational.factory.entity.AwardInfo;
import com.zwh.se.design_pattern.creational.factory.entity.ResponseResult;

/**
 * 发放奖品接口
 *
 * @author yexi
 **/
public class DeliverController {

    //发放奖品
    public ResponseResult awardToUser(AwardInfo awardInfo) {

        try {
            IFreeGoods freeGoods = FreeGoodsFactory.getInstance(awardInfo.getAwardTypes());
            ResponseResult responseResult = freeGoods.sendFreeGoods(awardInfo);
            return responseResult;
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult("201", "奖品发放失败!");
        }
    }

}
